package com.mephi.oshs.view.elements;

import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.widgets.Widget;

public class Textable implements ITextable {

    private final Widget text;

    public Textable(Widget text) {
        this.text = text;
    }

    @Override
    public String getText() {
        if (this.text instanceof Text) {
            return ((Text) this.text).getText();
        }
        throw new UnsupportedOperationException("getText(): Can't get text from given widget: " + this.text);
    }

    @Override
    public void setText(String text) {
        if (this.text instanceof Text) {
            ((Text) this.text).setText(text);
        }
    }
}
